<template>

	<view class="">


		<view class=""
			style="height: 240px;background-color: #FFFFFF;display: flex;flex-direction: column;align-items: center;">
			<image src="../../static/download.png" style="width: 110px;height: 99px;margin-top: 40px;" mode=""></image>
			<text style="color: #333333; font-size: 20px;font-weight: 500;margin-top: 30px;">您的借款申请已提交</text>
			<text style="color: #C53E3E;margin-top: 10px;font-size: 18px;">请耐心等待线下贷款专员联系您</text>
		</view>

		<view class="" style="background-color: #F3F7FA;height: 500px;">
			<view class="" style="padding: 16px 40px 128px 40px;height: 80px;">
				<text style="color: #8B8B8B;font-size: 13px;">为保障您的资金安全，请不要相信任何在放款前需要支付费用的信息、邮件、电话等，并注意保护您的个人隐私信息。
					如您需要帮助，请及时联系APP内在线客服。</text>
			</view>


		<!-- 	<view class="" @click="getApk" style="width: 100%;height: 90px;">
				<image src="../../static/xiazaibutton.png" mode="aspectFit"
					style="position: fixed;width: 100%;top: 520px;left: 0;"></image>

			</view> -->

		</view>

		<view class="mask" v-if="showmask">
			<view class="" style="width: 100%;height: 700px;text-align: center;margin: 0;display: flex;	flex-direction: column;
			
			align-items: center;
			justify-content: center;">
				<text style="color: #FFFFFF;font-size: 20px;">点击右上角···按钮 </text> <text
					style="color: #FFFFFF;font-size: 20px; ">选择在浏览器中打开下载APP </text>
			</view>

		</view>






	</view>


</template>

<script>
	import Mask from '../mask/mask.vue';
	export default {
		components: {
			Mask
		},
		data() {

			return {

				andoridUrl: '',
				channelCode: '',
				showmask: false,
				softType: ''
			}
		},

		onLoad() {
			// this.getAndoridUrl().then(()=>);
			this.softType = uni.getStorageSync('softType')
			this.isWeiXinLogin();
			this.shunxu();

			// this.getApk();



		},
		onReady() {
			// this.getApk();
		},
		methods: {

			async shunxu() {
				await this.getAndoridUrl();

				this.getApk()
			},

			//判断是否微信登陆
			isWeiXinLogin() {
				var ua = window.navigator.userAgent.toLowerCase();
				console.log(
					ua
				); //mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
				if (ua.match(/MicroMessenger/i) == 'micromessenger') {
					this.showmask = true;
					return true;

				} else {
					return false;
				}
			},
			async getAndoridUrl() {
				const res = await this.$myRequest({
					url: '/mkt/open/release/url',
					method: 'get',


				})
				this.andoridUrl = res.data.retData[0].appUrl
				console.log(this.andoridUrl)

			},
			async getApk() {



				await this.save()
				if (this.isWeiXinLogin()) {
					uni.showToast({
						icon: 'none',
						title: '点击右上角 ··· 在浏览器中打开下载',
						duration: 3000
					})
					return;
				}

				let platform = uni.getSystemInfoSync().platform;
				console.log(platform)
				if (platform == 'android') {
					try {


						uni.showToast({
							title: '正在下载。。。',
							icon: 'loading'
						})
						window.location.href = this.andoridUrl;
					} catch (e) {
						alert("error:" + e.message);
					}

				} else {
					try {
						uni.showToast({
							title: '正在下载。。。',
							icon: 'loading'
						})
						window.location.href =
						'https://apps.apple.com/cn/app/%E8%A2%8B%E9%BC%A0%E5%9C%88/id1577159458';

					} catch (e) {
						alert("error:" + e.message);
					}
				}




			},
			async save() {



				this.channelCode = uni.getStorageSync('channelCode')
				console.log('获取到的渠道号：', this.channelCode)




				let platform = uni.getSystemInfoSync().platform;

				if (platform == 'android') {
					this.osName = 'ANDROID';

				} else if (platform == 'ios') {
					this.osName = 'IOS';

				} else {
					this.osName = platform;
				}



				await this.$myRequest({
					url: '/mkt/flow/in/save',
					method: 'post',
					data: {
						'softType': this.softType,
						'clientVersion': '1.0.1',
						'apiVersion': '2',
						'channelCode': this.channelCode,
						'actionType': '5',
						'osName': this.osName
					}

				})


			},
			getRequestParams() {
				let url = location.href;
				let requestParams = {};
				if (url.indexOf("?") !== -1) {
					let str = url.substr(url.indexOf("?") + 1); //截取?后面的内容作为字符串
					console.log(str, '?后面的内容');
					let strs = str.split("&"); //将字符串内容以&分隔为一个数组
					console.log(strs, '以&切割的数组');
					for (let i = 0; i < strs.length; i++) {
						requestParams[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
						// 将数组元素中'='左边的内容作为对象的属性名，'='右边的内容作为对象对应属性的属性值
					}
				}
				// console.log(theRequest, "处理后的对象");
				return requestParams;
			},


		},


	}
</script>


<style lang="less">
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: #000000;
		opacity: 0.7;
		z-index: 99;
	}
</style>
